/************************************************************************/
/*    Author: Scott Bevin                                               */
/************************************************************************/

#include "OctTree.h"
#include "OctTreeIterator.h"

namespace XF
{
	OctTree::OctTree(OctTree &copyTree)
	{
		mRootNode = new OctTreeNode(*copyTree.mRootNode);
	}

	OctTree::OctTree(float x, float y, float z, float width, float height, float depth, int targetObjects, int maxHeirachyDepth)
	{
		mRootNode = new OctTreeNode(NULL, 0, x, y, z, width, height, depth);
		mRootNode->MaxDepth(maxHeirachyDepth);
		mRootNode->TargetObjects(targetObjects);
	}

	OctTree::~OctTree()
	{
		delete mRootNode;
	}

	int OctTree::GetNoOfObjects()
	{
		int count = 0;

		OctTreeIterator it(mRootNode);

		while(!it.End())
		{
			count += it.CurrentNode()->GetNoOfObjectsThisNodeHolds();

			it.Increment();
		}

		return count;
	}
}